﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;


namespace AppFx.Grammatica
{
	public class GrammaticaLanguageService : LanguageService
	{
		private LanguagePreferences _LanguagePreferences;
		private TextScanner _Scanner;

		public GrammaticaLanguageService()
		{
			
		}
		public override IScanner GetScanner(IVsTextLines buffer)
		{
			if (_Scanner == null)
			{
				_Scanner = new TextScanner(buffer);
			}
			return _Scanner;
		}


		public override LanguagePreferences GetLanguagePreferences()
		{
			if (_LanguagePreferences == null)
			{
				_LanguagePreferences = new LanguagePreferences(this.Site, typeof(GrammaticaLanguageService).GUID, this.Name);
				_LanguagePreferences.Init();
			}
			return _LanguagePreferences;
		}

		public override AuthoringScope ParseSource(ParseRequest req)
		{
			return new GrammaticaAuthoringScope();
		}

		public override string Name
		{
			get { return "Grammatica"; }
		}

		public override string GetFormatFilterList()
		{
			return null;
		}
	}

	internal class TextScanner : IScanner
	{
		private IVsTextBuffer _Buffer;
		string _Source;

        public TextScanner(IVsTextBuffer buffer)
        {
            _Buffer = buffer;
        }

        bool IScanner.ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
        {
            tokenInfo.Type = TokenType.Unknown;
            tokenInfo.Color = TokenColor.Text;
            return true;
        }

        void IScanner.SetSource(string source, int offset)
        {
            _Source = source.Substring(offset);
        }

	}

	internal class GrammaticaAuthoringScope : AuthoringScope
	{
		public override string GetDataTipText(int line, int col, out TextSpan span)
		{
			span = new TextSpan();
			return null;
		}

		public override Declarations GetDeclarations(IVsTextView view,
													 int line,
													 int col,
													 TokenInfo info,
													 ParseReason reason)
		{
			return null;
		}

		public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
		{
			span = new TextSpan();
			return null;
		}

		public override Methods GetMethods(int line, int col, string name)
		{
			return null;
		}

	}
}
